#!/bin/bash
#启动是传入prod或者dev
str=""
if test -z $1; then
    str="dev"
elif [ "$1" = "dev" ] || [ "$1" = "prod" ]; then
    str=$1
else
    str="dev"
fi
echo "the app start enviroment is $str"
pm2 start ./ecosystem.config.js --env $str
#pm2 install pm2-logrotate
#压缩日志
pm2 set pm2-logrotate:compress false
#保留1000份日志 
pm2 set pm2-logrotate:retain 1000
#日志文件大小10G,10M,10k
pm2 set pm2-logrotate:max_size 100M
#日志文件名字格式,仅支持当前格式
pm2 set pm2-logrotate:dateFormat 'YYYY-MM-DD_HH-mm-ss'
#pm2 set pm2-logrotate:rotateInterval '* */1 * * * *'
#每天0点日志分割
pm2 set pm2-logrotate:rotateInterval '0 0 * * *'
